#pragma once
namespace ne{
int luabind_pcall(lua_State* L);
//int lua_pcall

class PhysicsWorld;
class StateListener;
class InputSystem;
class GameTime;
class LuaEngine {
public:
	LuaEngine(void);

	void AddPath(const Ogre::String& path) {m_paths.push_back(path);}
	bool Init(PhysicsWorld* physicsWorld,StateListener* stateListener,InputSystem* inputSystem,GameTime* gameTime);
	void Shut();

	void Load(const char* filename);
	void Call(const char* functionName);

	void CheckFiles(class GameTime* gameTime);

	lua_State* GetState() const { return m_L; }

private:
	static int AtPanic(lua_State* s);
	bool LoadScripts(const Ogre::String& path);
	std::vector<Ogre::String> m_paths;
	lua_State* m_L;

#ifdef DEV_MODE
	float m_timeLimit;
	float m_timer;
#ifdef WIN32
	struct LuaFileInfo{
		LuaFileInfo(const Ogre::String& filename, time_t time) : m_filename(filename), m_time(time){}
		LuaFileInfo(void) : m_filename(Ogre::StringUtil::BLANK), m_time(0) {}
		Ogre::String m_filename;
		time_t m_time;
	};
	std::vector<LuaFileInfo> m_files;
#endif
#endif
};
}